
PWD := $(shell pwd)
CC=g++
CFLAGS := -Wall -I.
#CFLAGS := -O3 -Wall -I.
DEBUG_CFLAGS := -g -Wall 
LDLIBS := -lsfml-graphics -lsfml-window -lsfml-system -lsfml-network
BIN_OUTPUT := ../bin/
BIN_FILE := solgame
SERVER_BIN_FILE := solgame_server
EXT_LIBS := ../lib/linux64/libBox2D.a

all: linux64

server: linux64server linux64client

linux64: main.o menu.o play.o phys_body.o ship.o util.o $(EXT_LIBS)
	mkdir -p $(BIN_OUTPUT)
	$(CC) $^ $(CFLAGS) $(LDLIBS) -o $(BIN_OUTPUT)$(BIN_FILE)
	cp template_runscript.sh ../run.sh
	echo "./$(BIN_FILE)" >> ../run.sh
	chmod +x ../run.sh

linux64client: game.o phys_body.o $(EXT_LIBS)
	mkdir -p $(BIN_OUTPUT)
	$(CC) $^ $(CFLAGS) $(LDLIBS) -o $(BIN_OUTPUT)solgame_client
	cp template_runscript.sh ../run.sh
	echo "./solgame_client" >> ../run.sh
	chmod +x ../run.sh

linux64server: server_main.o phys_body.o $(EXT_LIBS)
	mkdir -p $(BIN_OUTPUT)
	$(CC) $^ $(CFLAGS) $(LDLIBS) -o $(BIN_OUTPUT)$(SERVER_BIN_FILE)
	cp template_runscript.sh ../run.sh
	echo "./$(SERVER_BIN_FILE)" >> ../run.sh
	chmod +x ../run.sh

#debug: game.o rtscamera.o ship.o body.o system.o pugixml/pugixml.o event.
#	mkdir -p $(BIN_OUTPUT)
#	$(CC) $^ $(DEBUG_CFLAGS) $(LDLIBS) -o $(BIN_OUTPUT)$(BIN_FILE)
#	cp template_debugscript.sh ../run.sh
#	chmod +x ../run.sh

main.o: main.cpp 
	$(CC) $(CFLAGS) -c main.cpp 

menu.o: menu.cpp 
	$(CC) $(CFLAGS) -c menu.cpp 

play.o: play.cpp 
	$(CC) $(CFLAGS) -c play.cpp 

server_main.o: server_main.cpp
	$(CC) $(CFLAGS) -c server_main.cpp 

game.o: game.cpp
	$(CC) $(CFLAGS) -c game.cpp 

phys_body.o: phys_body.cpp
	$(CC) $(CFLAGS) -c phys_body.cpp 

ship.o: ship.cpp 
	$(CC) $(CFLAGS) -c ship.cpp 

util.o: util.cpp 
	$(CC) $(CFLAGS) -c util.cpp 
#game.o: game.cpp 
#	$(CC) $(CFLAGS) -c game.cpp 

#targets.o: targets.cpp 
#	$(CC) $(CFLAGS) -c targets.cpp 

#followcamera.o: followcamera.cpp
#	$(CC) $(CFLAGS) -c followcamera.cpp

#ship.o: ship.cpp
#	$(CC) $(CFLAGS) -c ship.cpp

#util.o: util.cpp
#	$(CC) $(CFLAGS) -c util.cpp

#body.o: body.cpp
#	$(CC) $(CFLAGS) -c body.cpp

#system.o: system.cpp
#	$(CC) $(CFLAGS) -c system.cpp

#event.o: event.cpp
#	$(CC) $(CFLAGS) -c event.cpp

#pugixml/pugixml.o: pugixml/pugixml.cpp

#grid/CGridSceneNode.o: grid/CGridSceneNode.cpp


#CSceneNodeAnimatorMovableFlyCircle.o: CSceneNodeAnimatorMovableFlyCircle.cpp

clean:
	rm -rf *.o ../run.sh ../bin 
